package com.jxj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jxj.dao.ResumeMapper;
import com.jxj.entity.GenResumeVO;
import com.jxj.entity.gen.TResumeMsg;
import com.jxj.service.ResumeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author Cambria
 * @creat 2021/8/14 11:02
 */
@Slf4j
@Service
public class ResumeServiceImpl extends ServiceImpl<ResumeMapper , TResumeMsg> implements ResumeService {
    @Autowired
    ResumeMapper resumeMapper;

    @Override
    public List<GenResumeVO> listResumeByOid(int orgId) {
        QueryWrapper<TResumeMsg> wrapper = new QueryWrapper<>();
        wrapper.eq("oId" , orgId);
        List<TResumeMsg> tResumeMsgs = resumeMapper.selectList(wrapper);

        List<GenResumeVO> data = new ArrayList<>();
        for (TResumeMsg msg : tResumeMsgs) {
            GenResumeVO vo = new GenResumeVO();
            vo.setId(String.valueOf(msg.getId()));
            vo.setPerson(msg.getRealName());
            vo.setTime(DateTimeFormatter.ofPattern("yy-MM-dd").format(msg.getAddTime()));
            data.add(vo);
        }

        return data;
    }
}
